Azure Functions is a serverless compute service that enables you to run event-triggered code without explicitly provisioning or managing infrastructure. It's suitable for various application scenarios.
1. Creating an HTTP-triggered Function in the Azure Portal:
2. Creating a Timer-triggered Function using Azure CLI:
az functionapp create --resource-group MyResourceGroup --name MyFunctionApp --consumption-plan-location eastus --runtime dotnet
az function create --name MyTimerFunction --resource-group MyResourceGroup --functionapp MyFunctionApp --template "TimerTrigger" --cron "0 */5 * * * *"
3. Integrating Azure Functions with Azure Storage Queue:
public static class QueueTriggerFunction
{
[FunctionName("QueueTriggerFunction")]
public static void Run(
[QueueTrigger("myqueue-items", Connection = "AzureWebJobsStorage")] string myQueueItem,
ILogger log)
{
log.LogInformation($"C# Queue trigger function processed message: {myQueueItem}");
}
}
4. Using Azure Functions Extensions:
public static void Run(
[BlobTrigger("mycontainer/{name}", Connection = "AzureWebJobsStorage")] Stream myBlob,
string name,
ILogger log)
{
log.LogInformation($"C# Blob trigger function processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}